#include <iostream>
#include <fstream>

#include "scene.h"
#include "view.h"

int main(int argc, char **argv)
{
  std::string filename;
  if (argc < 2)
  {
    std::cin >> filename;
  }
  else
  {
    filename = argv[1];
  }

  std::ifstream inData(filename.c_str());
  Scene scene;
  View view(&scene);
  
  std::cout << "Loading..." << std::endl;
  view.loadAttributes(inData);
  scene.loadAttributes(inData);


  std::cout << "Scene Loaded... Rendering" << std::endl;
  view.render();
  std::cout << "Success!" << std::endl;

  if (argc==3)
  {
    filename = argv[2];
    std::ofstream outData(filename.c_str());
    view.savePpm(outData);
    outData.close();
  }

  return 0;
}
